import request from "@/utils/request";
import {
  ParamsType,
  ProjectManagerType,
  NewProjectManagerType,
  ProjectUnitFrom,
  ProjectPersonForm,
  ProjectTeamForm,
  PersonInfoInForm,
  PayrollDetailForm,
} from "@/api/manager/project/types";

/**
 * 获取项目管理列表
 */
export function getProjectMagList(data: ParamsType) {
  return request({
    url: "/api/v1/manager/project/project_page",
    method: "get",
    params: data,
  });
}

/**
 * 获取项目管理列表
 */
export function getProjectMagInfo(projectId: number) {
  return request({
    url: `api/v1/manager/project/${projectId}/projectform`,
    method: "get",
  });
}

/**
 * 新增项目
 */
export function addProject(data: ProjectManagerType) {
  return request({
    url: "/api/v1/manager/project/create_project",
    method: "post",
    data: data,
  });
}

/**
 * new新增项目
 */
export function new_addProject(data: NewProjectManagerType) {
  console.log("areaCodeareaCodeareaCode", JSON.stringify(data));
  return request({
    url: "/api/v1/manager/project/create_project",
    method: "post",
    data: data,
  });
}

/**
 * 修改项目
 */
export function editProject(id: number, data: ProjectManagerType) {
  return request({
    url: "/api/v1/manager/project/update_project/" + id,
    method: "put",
    data: data,
  });
}

/**
 * new修改项目
 */
export function new_editProject(id: number, data: NewProjectManagerType) {
  return request({
    url: "/api/v1/manager/project/update_project/" + id,
    method: "put",
    data: data,
  });
}

/**
 * 删除项目
 */
export function deleteProject(id: number) {
  return request({
    url: "/api/v1/manager/project/delete_project/" + id,
    method: "delete",
  });
}

/**
 * new删除项目
 */
export function new_deleteProject(id: number) {
  return request({
    url: "/api/v1/manager/project/delete_project/" + id,
    method: "delete",
  });
}

/**
 * 获取参建企业列表
 */
export function getProjectUnitList(data: ParamsType) {
  return request({
    url: "/api/v1/manager/projectcorp/page",
    method: "get",
    params: data,
  });
}

/**
 * 获取参建企业信息
 */
export function getProjectUnitInfo(projectId: number) {
  return request({
    url: `api/v1/manager/projectcorp/${projectId}/form`,
    method: "get",
  });
}

/**
 * 新增参建企业
 */
export function addProjectUnit(data: ProjectUnitFrom) {
  console.log("addProjectUnit", JSON.stringify(data));

  return request({
    url: "/api/v1/manager/projectcorp/create",
    method: "post",
    data: data,
  });
}

/**
 * 修改项目
 */
export function editProjectUnit(id: number, data: ProjectUnitFrom) {
  return request({
    url: "/api/v1/manager/projectcorp/" + id,
    method: "put",
    data: data,
  });
}

/**
 * 删除项目
 */
export function deleteProjectUnit(id: number) {
  return request({
    url: "/api/v1/manager/projectcorp/" + id,
    method: "delete",
  });
}

/**
 * 参建单位进场
 */
export function corpEnterArena(ids: string, time: Date) {
  return request({
    url: "/api/v1/manager/projectcorp/enterArena/" + ids,
    method: "put",
    params: { time: time },
  });
}

/**
 * 参建单位离场
 */
export function corpAppearStage(ids: string, time: Date) {
  return request({
    url: "/api/v1/manager/projectcorp/appearStage/" + ids,
    method: "put",
    params: { time: time },
  });
}

/**
 * 获取现场管理人员列表
 */
export function getProjectPersonList(data: ParamsType) {
  return request({
    url: "/api/v1/manager/projectmanager/page",
    method: "get",
    params: data,
  });
}

/**
 * 获取现场管理人员信息
 */
export function getProjectPersonInfo(id: number) {
  return request({
    url: `api/v1/manager/projectmanager/${id}/form`,
    method: "get",
  });
}

/**
 * 新增现场管理人员
 */
export function addProjectPerson(data: ProjectPersonForm) {
  return request({
    url: "/api/v1/manager/projectmanager/create",
    method: "post",
    data: data,
  });
}

/**
 * 修改现场管理人员信息
 */
export function editProjectPerson(id: number, data: ProjectPersonForm) {
  return request({
    url: "/api/v1/manager/projectmanager/" + id,
    method: "put",
    data: data,
  });
}

/**
 * 删除现场管理人员
 */
export function deleteProjectPerson(id: number) {
  return request({
    url: "/api/v1/manager/projectmanager/" + id,
    method: "delete",
  });
}

/**
 * 获取项目班组列表
 */
export function getProjectTeamList(data: ParamsType) {
  return request({
    url: "/api/v1/manager/projectgroup/page",
    method: "get",
    params: data,
  });
}

/**
 * 获取项目班组下拉列表
 */
export function getProjectTeamPulldownList() {
  return request({
    url: "/api/v1/manager/projectgroup/pulldown",
    method: "get",
  });
}

/**
 * 获取班组信息
 */
export function getProjectTeamInfo(id: number) {
  return request({
    url: `api/v1/manager/projectgroup/${id}/form`,
    method: "get",
  });
}

/**
 * 新增班组
 */
export function addProjectTeam(data: ProjectTeamForm) {
  return request({
    url: "/api/v1/manager/projectgroup/create",
    method: "post",
    data: data,
  });
}

/**
 * 修改班组
 */
export function editProjectTeam(id: number, data: ProjectTeamForm) {
  return request({
    url: "/api/v1/manager/projectgroup/" + id,
    method: "put",
    data: data,
  });
}

/**
 * 删除班组
 */
export function deleteProjectTeam(id: number) {
  return request({
    url: "/api/v1/manager/projectgroup/" + id,
    method: "delete",
  });
}

/**
 * 班组进场
 */
export function teamEnterArena(ids: string, time: Date) {
  return request({
    url: "/api/v1/manager/projectgroup/enterArena/" + ids,
    method: "put",
    params: { time: time },
  });
}

/**
 * 班组离场
 */
export function teamAppearStage(ids: string, time: Date) {
  return request({
    url: "/api/v1/manager/projectgroup/appearStage/" + ids,
    method: "put",
    params: { time: time },
  });
}

/**
 * 获取班组人员列表
 */
export function getProjectTeamMemberList(data: ParamsType) {
  return request({
    url: "/api/v1/manager/projectgroupmember/page",
    method: "get",
    params: data,
  });
}

/**
 * 根据班组ID 获取班组人员列表
 */
export function getProjectTeamMemberListByTeamId(id) {
  return request({
    url: "/api/v1/manager/projectgroupmember/getProjectGroupMemberByGroupId/" + id,
    method: "get",
  });
}

/**
 * 获取班组成员信息
 */
export function getProjectTeamMemberInfo(id: number) {
  return request({
    url: `api/v1/manager/projectgroupmember/${id}/form`,
    method: "get",
  });
}

/**
 * 新增班组成员
 */
export function addProjectTeamMember(data: ProjectTeamForm) {
  return request({
    url: "/api/v1/manager/projectgroupmember/create",
    method: "post",
    data: data,
  });
}

/**
 * 修改班组成员
 */
export function editProjectTeamMember(id: number, data: ProjectTeamForm) {
  return request({
    url: "/api/v1/manager/projectgroupmember/" + id,
    method: "put",
    data: data,
  });
}

/**
 * 删除班组成员
 */
export function deleteProjectTeamMember(id: number) {
  return request({
    url: "/api/v1/manager/projectgroupmember/" + id,
    method: "delete",
  });
}

/**
 * 获取专户列表
 */
export function getProjectAccountList(data: ParamsType) {
  return request({
    url: "/api/v1/manager/projectspecialaccount/page",
    method: "get",
    params: data,
  });
}

/**
 * 获取专户信息
 */
export function getProjectAccountInfo(id: number) {
  return request({
    url: `api/v1/manager/projectspecialaccount/${id}/form`,
    method: "get",
  });
}

/**
 * 新增专户成员
 */
export function addProjectAccount(data: ProjectTeamForm) {
  return request({
    url: "/api/v1/manager/projectspecialaccount/create",
    method: "post",
    data: data,
  });
}

/**
 * 修改专户成员
 */
export function editProjectAccount(id: number, data: ProjectTeamForm) {
  return request({
    url: "/api/v1/manager/projectspecialaccount/" + id,
    method: "put",
    data: data,
  });
}

/**
 * 删除专户成员
 */
export function deleteProjectAccount(id: number) {
  return request({
    url: "/api/v1/manager/projectspecialaccount/" + id,
    method: "delete",
  });
}

/**
 * 根据身份证号获取人员信息
 */
export function getPersonInfoByCardId(cardNo: number) {
  return request({
    url: `api/v1/manager/person/` + cardNo,
    method: "get",
  });
}

/**
 * 获取人员列表
 */
export function getPersonInfoList(data: ParamsType) {
  return request({
    url: "/api/v1/manager/person/page",
    method: "get",
    params: data,
  });
}

/**
 * 获取人员信息
 */
export function getPersonInfo(id: number) {
  return request({
    url: `api/v1/manager/person/${id}/form`,
    method: "get",
  });
}

/**
 * 登记人员信息
 */
export function inPersonInfo(data: PersonInfoInForm) {
  return request({
    url: "/api/v1/manager/person/add",
    method: "post",
    data: data,
  });
}

/**
 * 人员进场
 */
export function personEnterArena(ids: string, time: Date) {
  return request({
    url: "/api/v1/manager/person/enterArena/" + ids,
    method: "put",
    params: { time: time },
  });
}

/**
 * 人员离场
 */
export function personAppearStage(ids: string, time: Date) {
  return request({
    url: "/api/v1/manager/person/appearStage/" + ids,
    method: "put",
    params: { time: time },
  });
}

/**
 * 获取人员银行信息列表
 */
export function getPersonBankList(data: ParamsType) {
  return request({
    url: "/api/v1/manager/personbank/page",
    method: "get",
    params: data,
  });
}

/**
 * 获取人员银行信息
 */
export function getPersonBankInfo(id: number) {
  return request({
    url: `api/v1/manager/personbank/${id}/form`,
    method: "get",
  });
}

/**
 * 新增人员银行信息
 */
export function addPersonBank(data: ProjectTeamForm) {
  return request({
    url: "/api/v1/manager/personbank/create",
    method: "post",
    data: data,
  });
}

/**
 * 修改人员银行信息
 */
export function editPersonBank(id: number, data: ProjectTeamForm) {
  return request({
    url: "/api/v1/manager/personbank/" + id,
    method: "put",
    data: data,
  });
}

/**
 * 删除人员银行信息
 */
export function deletePersonBank(id: number) {
  return request({
    url: "/api/v1/manager/personbank/" + id,
    method: "delete",
  });
}

/**
 * 银行信息下拉列表
 */
export function getPersonBankPullDownList(data: any) {
  return request({
    url: "/api/v1/manager/personbank/pulldown",
    method: "get",
    params: data,
  });
}

/**
 * 获取考勤明细列表
 */
export function getAttendanceList(data: ParamsType) {
  return request({
    url: "/api/v1/manager/checkindetail/page",
    method: "get",
    params: data,
  });
}

/**
 * 获取工资单列表
 */
export function getPayrollList(data: ParamsType) {
  return request({
    url: "/api/v1/manager/wagepayroll/page",
    method: "get",
    params: data,
  });
}

/**
 * 获取工资单信息
 */
export function getPayrollInfo(id: number) {
  return request({
    url: `api/v1/manager/wagepayroll/${id}/form`,
    method: "get",
  });
}

/**
 * 获取工资单审核记录
 */
export function getPayrollInfoAuditLogs(id: number) {
  return request({
    url: "/api/v1/manager/wagepayroll/auditLogs?id=" + id,
    method: "get",
  });
}

/**
 * 新增工资单信息
 */
export function addPayroll(data: ProjectTeamForm) {
  return request({
    url: "/api/v1/manager/wagepayroll/create",
    method: "post",
    data: data,
  });
}

/**
 * 修改工资单信息
 */
export function editPayroll(id: number, data: ProjectTeamForm) {
  return request({
    url: "/api/v1/manager/wagepayroll/" + id,
    method: "put",
    data: data,
  });
}

/**
 * 提交工资单信息
 */
export function submitPayroll(id: number) {
  return request({
    url: "/api/v1/manager/wagepayroll/submit/" + id,
    method: "post",
  });
}
/**
 * 删除工资单信息
 */
export function deletePayroll(id: number) {
  return request({
    url: "/api/v1/manager/wagepayroll/" + id,
    method: "delete",
  });
}

/**
 * 获取工资单明细详情信息
 */
export function getPayrollDetail(id: number) {
  return request({
    url: "/api/v1/manager/wagepayrolldetail/" + id,
    method: "get",
  });
}

/**
 * 提交工资单明细详情信息
 */
export function putPayrollDetail(id: number, data: PayrollDetailForm) {
  return request({
    url: "/api/v1/manager/wagepayrolldetail/addWagePayrollDetails/" + id,
    method: "post",
    data: data,
  });
}

/**
 * 导出工资明细模板
 */
export function downloadPayroll(id: number) {
  return request({
    url: "/api/v1/manager/wagepayroll/exportTemplate/" + id,
    method: "get",
    responseType: "arraybuffer",
  });
}

/**
 * 导出工资明细模板
 */
export function exportPayrollDetail(id: number) {
  return request({
    url: "/api/v1/manager/wagepayroll/exportDetail/" + id,
    method: "get",
    responseType: "arraybuffer",
  });
}

/**
 * 获取保证金账户列表
 */
export function getSecurityDepositList(data: ParamsType) {
  return request({
    url: "/api/v1/manager/projectsecuritydeposit/page",
    method: "get",
    params: data,
  });
}

/**
 * 获取保证金账户列表(下拉)
 */
export function getSecurityDepositPullDown(data: ParamsType) {
  return request({
    url: "/api/v1/manager/projectsecuritydeposit/pulldown",
    method: "get",
    params: data,
  });
}

/**
 * 获取保证金账户信息
 */
export function getSecurityDeposit(id: number) {
  return request({
    url: `api/v1/manager/projectsecuritydeposit/${id}/form`,
    method: "get",
  });
}

/**
 * 新增保证金账户成员
 */
export function addSecurityDeposit(data: ProjectTeamForm) {
  return request({
    url: "/api/v1/manager/projectsecuritydeposit/create",
    method: "post",
    data: data,
  });
}

/**
 * 修改保证金账户成员
 */
export function editSecurityDeposit(id: number, data: ProjectTeamForm) {
  return request({
    url: "/api/v1/manager/projectsecuritydeposit/" + id,
    method: "put",
    data: data,
  });
}

/**
 * 删除保证金账户成员
 */
export function deleteSecurityDeposit(id: number) {
  return request({
    url: "/api/v1/manager/projectsecuritydeposit/" + id,
    method: "delete",
  });
}

/**
 * 获取保证金收支信息列表
 */
export function getSecurityDepositRecordsList(data: ParamsType) {
  return request({
    url: "/api/v1/manager/projectsecuritydepositrecords/page",
    method: "get",
    params: data,
  });
}

/**
 * 获取保证金收支信息
 */
export function getSecurityDepositRecords(id: number) {
  return request({
    url: `api/v1/manager/projectsecuritydepositrecords/${id}/form`,
    method: "get",
  });
}

/**
 * 新增保证金收支信息
 */
export function addSecurityDepositRecords(data: ProjectTeamForm) {
  return request({
    url: "/api/v1/manager/projectsecuritydepositrecords/create",
    method: "post",
    data: data,
  });
}

/**
 * 修改保证金收支信息
 */
export function editSecurityDepositRecords(id: number, data: ProjectTeamForm) {
  return request({
    url: "/api/v1/manager/projectsecuritydepositrecords/" + id,
    method: "put",
    data: data,
  });
}

/**
 * 删除保证金收支信息
 */
export function deleteSecurityDepositRecords(id: number) {
  return request({
    url: "/api/v1/manager/projectsecuritydepositrecords/" + id,
    method: "delete",
  });
}

/**
 * 获取保证金支付明细列表
 */
export function getSecurityDepositPaymentDetailsList(data: ParamsType) {
  return request({
    url: "/api/v1/manager/projectsecuritydepositpaymentdetails/page",
    method: "get",
    params: data,
  });
}

/**
 * 获取保证金支付明细
 */
export function getSecurityDepositPaymentDetails(id: number) {
  return request({
    url: `api/v1/manager/projectsecuritydepositpaymentdetails/${id}/form`,
    method: "get",
  });
}

/**
 * 新增保证金支付明细
 */
export function addSecurityDepositPaymentDetails(data: ProjectTeamForm) {
  return request({
    url: "/api/v1/manager/projectsecuritydepositpaymentdetails/create",
    method: "post",
    data: data,
  });
}

/**
 * 修改保证金支付明细
 */
export function editSecurityDepositPaymentDetails(id: number, data: ProjectTeamForm) {
  return request({
    url: "/api/v1/manager/projectsecuritydepositpaymentdetails/" + id,
    method: "put",
    data: data,
  });
}

/**
 * 删除保证金支付明细
 */
export function deleteSecurityDepositPaymentDetails(id: number) {
  return request({
    url: "/api/v1/manager/projectsecuritydepositpaymentdetails/" + id,
    method: "delete",
  });
}
